/*
 * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package io.iec.edp.caf.lock.service.api.api;

import io.iec.edp.caf.lockservice.api.*;

import java.time.Duration;
import java.util.List;

public interface LockExtension {


    LockResult addLock(String mkId, String dataCat, String dataId, DataLockOptions option, String funcId, String comment);


    BatchLockResult addBatchLock(String mkId, String dataCat, List<String> dataIds, String groupId, Duration persistenceTime, String funcId, String comment);


    /**
     * 根据锁编号解锁
     * @param lockID 锁编号
     * @return 是否成功的标识
     */
    boolean removeLock(String lockID);

    boolean removeLock(RemoveLockInstance removeLockInstance);

    /**
     * 解除所有进程号为sessionId的锁
     * @param sessionId 锁对应的进程号，区别于当前进程号
     * @param tenantId 租户编号
     * @return 是否清除成功，true：表示成功  false：表示失败
     */
    boolean removeSessionLock(String sessionId, int tenantId);

    /**
     * 批量解锁
     * @param groupId 锁批量编号
     * @return 是否删批量锁成功
     */
    boolean removeBatchLock(String groupId);



    boolean removeBatchLockByContext(String contextId);

    /**
     * 根据gropuId获取dataIds
     * @param groupId
     * @return
     */
    List<String>  getDataIds(String groupId);

    LockStatus getLockStatus(LockEntity lockEntity);

}
